/**
 * 抽象工厂类：对工厂抽象化，便于工厂的扩展;
 */
public class AbstractFactoryPattern {
    public static void main(String[] args) {
        //man
        PersonFactory manPersonFactory = new ManPersonFactory();
        Person man = manPersonFactory.createPerson();
        man.sex();
        //woman
        PersonFactory womanPersonFactory = new WomanPersonFactory();
        Person woman = womanPersonFactory.createPerson();
        woman.sex();
    }
}

//工厂类
abstract class Person{
    public abstract void sex();
}
//工厂业务类:dog
class Man extends Person{
    public void sex(){
        System.out.println("this is a man！！！");
    }
}
//工厂业务类:cat
class Woman extends Person{
    public void sex(){
        System.out.println("this is a woman！！！");
    }
}
//抽象工厂:对工厂抽象化，不同的工厂创建不同的对象。
abstract class PersonFactory{
    public abstract Person createPerson();
}
class WomanPersonFactory extends PersonFactory{
    public Person createPerson(){
        return new Woman();
    }
}

class ManPersonFactory extends PersonFactory{
    public Person createPerson(){
        return new Man();
    }
}

